<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;
use OT\DataDictionary;

/**
 * 前台首页控制器
 * 主要获取首页聚合数据
 */
class ProductController extends HomeController
{

	//系统首页
    public function index()
    {
		$products = new \Document\Model\ContentArticle\Home\GetProductCategoryModel();
        $category_title= $products->get();
		
		$this->assign('category_title',$category_title);
		
		$type_id=I('get.id');
		$document=D('Document');
		$content_article=D('DocumentContentArticle');
		if(empty($type_id)){
			
			$product_list=$category_title[0];
			
			$condition['id']=$category_title[0]['id'];
			$product_content=$content_article->where($condition)->select();
			$product_content_main=$product_content[0];
			
		}else{
			$product = new \Document\Model\ContentArticle\Home\GetProductCategoryModel();
			$product_title= $product->getContent($type_id);
			$product_list=$product_title[0];
			
			$condition['id']=$product_title[0]['id'];
			$product_content=$content_article->where($condition)->select();
			$product_content_main=$product_content[0];
		}
		$this->assign('type_id',$type_id);
		$this->assign('product_list', $product_list);
		$this->assign('product_content_main', $product_content_main);
        $this->display('index');
    }

  /*  public function carousel()
    {
        $carousel = new \Document\Model\Carousel\Home\GetIndexCarouselModel();
        $data = $carousel->get();
    }*/

}